package Pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.Map;

import static Driver.DriverSingleton.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class BasePage {

    WebDriver driver = getChromeDriver();
    Map<String,Object> vars = getVars();
    private LoginPageAgg loginPage = new LoginPageAgg();

    public BasePage login(){
        loginPage.goLoginPage().login("test5", "123456");
        waitForWindow(2000);
        assertThat(driver.getTitle(), is("首页"));
        return this;
    }

    //获取消息提示
    public String getMessage(){
        //弹出消息提示
        waitForWindow(2000);
        WebElement elementText = driver.findElement(By.cssSelector("div.el-message"));
        String info = elementText.getText();
        System.out.println(info);
        return info;
    }

    //获取弹窗
    public String getDialog(){
        waitForWindow(2000);
        WebElement element = driver.findElement(By.cssSelector("div.el-message-box__message"));
        String info = element.getText();
        System.out.println(info);
        return info;
    }
}
